Improve nomenclatural_type handling and add API glossary#254
Merged
Conversation
- Use safe navigation and respond_to? to check if object can call type_of_type - Return 'unknown' if object is nil or does not respond to type_of_type - This ensures consistency with the API documentation and handles edge cases gracefully
This file documents all enums (status_name, kind, rank) and special fields like nomenclatural_type that are used in the SeqCode Registry API. The nomenclatural_type field is documented as a hash object with a class key that can have values: Name, Genome, Strain, Other, or unknown. Other is included as it is returned by GenericTypeMaterial#type_of_type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR includes two improvements:
Code Improvement: Updated
app/views/names/_nomenclatural_type.json.jbuilderto safely handle cases where the object isnilor does not respond totype_of_type. The new logic uses Ruby's safe navigation operator (&.) andrespond_to?to ensure robustness, returning'unknown'as a fallback.Documentation Improvement: Added a new
docs/api_glossary.mdfile that documents all enums (status_name,kind,rank) and special fields likenomenclatural_typeused in the SeqCode Registry API. Thenomenclatural_typefield is now clearly documented as a hash object with aclasskey that can have values:Name,Genome,Strain,Other, orunknown. TheOthervalue is included as it is returned byGenericTypeMaterial#type_of_type.These changes improve both the reliability of the API and the clarity of its documentation.